home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / Certificate.java < prev    next >
Text File  |  1998-09-22  |  5KB  |  140 lines

  1. /*
  2.  * @(#)Certificate.java    1.16 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.security;
  16.  
  17. import java.io.*;
  18. import java.util.Date;
  19.  
  20. /**
  21.  * <p>This is an interface of abstract methods for managing an
  22.  * identity certificate. An identity certificate is a guarantee by a
  23.  * principal that a public key is that of another principal.  (A
  24.  * principal represents an entity such as an individual user or a
  25.  * group.)
  26.  *
  27.  * <p>In particular, this interface is intended to be a common
  28.  * abstraction for constructs that have different formats but
  29.  * important common uses.  For example, different types of
  30.  * certificates, such as X.509 certificates and PGP certificates,
  31.  * share general certificate functionality (the need to encode and
  32.  * decode certificates) and some types of information, such as a
  33.  * public key, the principal whose key it is, and the guarantor
  34.  * guaranteeing that the public key is that of the specified
  35.  * principal. So an implementation of X.509 certificates and an
  36.  * implementation of PGP certificates can both utilize the Certificate
  37.  * interface, even though their formats and additional types and
  38.  * amounts of information stored are different.
  39.  *
  40.  * <p><b>Important</b>: This interface is useful for cataloging and
  41.  * grouping objects sharing certain common uses. It does not have any
  42.  * semantics of its own. In particular, a Certificate object does not
  43.  * make any statement as to the <i>validity</i> of the binding. It is
  44.  * the duty of the application implementing this interface to verify
  45.  * the certificate and satisfy itself of its validity.
  46.  *
  47.  * @version     1.14 01/29/97
  48.  * @author Benjamin Renaud 
  49.  */
  50. public interface Certificate {
  51.  
  52.     /** 
  53.      * Returns the guarantor of the certificate, that is, the principal
  54.      * guaranteeing that the public key associated with this certificate
  55.      * is that of the principal associated with this certificate. For X.509
  56.      * certificates, the guarantor will typically be a Certificate Authority
  57.      *  (such as the United States Postal Service or Verisign, Inc.).
  58.      *
  59.      * @return the guarantor which guaranteed the principal-key
  60.      * binding.
  61.      */
  62.     public abstract Principal getGuarantor();
  63.     
  64.     /**
  65.      * Returns the principal of the principal-key pair being guaranteed by
  66.      * the guarantor.
  67.      *
  68.      * @return the principal to which this certificate is bound.  
  69.      */
  70.     public abstract Principal getPrincipal();
  71.  
  72.     /**
  73.      * Returns the key of the principal-key pair being guaranteed by
  74.      * the guarantor.
  75.      * 
  76.      * @return the public key that this certificate certifies belongs
  77.      * to a particular principal.  
  78.      */
  79.     public abstract PublicKey getPublicKey();
  80.  
  81.     /**
  82.      * Encodes the certificate to an output stream in a format that can
  83.      * be decoded by the <code>decode</code> method.
  84.      *
  85.      * @param stream the output stream to which to encode the
  86.      * certificate.
  87.      *
  88.      * @exception KeyException if the certificate is not
  89.      * properly initialized, or data is missing, etc.
  90.      *
  91.      * @exception IOException if a stream exception occurs while
  92.      * trying to output the encoded certificate to the output stream.
  93.      *
  94.      * @see #decode 
  95.      * @see #getFormat
  96.      */
  97.     public abstract void encode(OutputStream stream) 
  98.         throws KeyException, IOException;
  99.  
  100.     /**
  101.      * Decodes a certificate from an input stream. The format should be
  102.      * that returned by <code>getFormat</code> and produced by 
  103.      * <code>encode</code>.
  104.      *
  105.      * @param stream the input stream from which to fetch the data
  106.      * being decoded.
  107.      * 
  108.      * @exception KeyException if the certificate is not properly initialized,
  109.      * or data is missing, etc.
  110.      *
  111.      * @exception IOException if an exception occurs while trying to input
  112.      * the encoded certificate from the input stream.
  113.      *
  114.      * @see #encode 
  115.      * @see #getFormat
  116.      */
  117.     public abstract void decode(InputStream stream) 
  118.         throws KeyException, IOException;
  119.  
  120.  
  121.     /**
  122.      * Returns the name of the coding format. This is used as a hint to find
  123.      * an appropriate parser. It could be "X.509", "PGP", etc. This is
  124.      * the format produced and understood by the <code>encode</code>
  125.      * and <code>decode</code> methods.
  126.      * 
  127.      * @return the name of the coding format.
  128.      */
  129.     public abstract String getFormat();
  130.  
  131.     /**
  132.      * Returns a string that represents the contents of the certificate.
  133.      *
  134.      * @param detailed whether or not to give detailed information
  135.      * about the certificate.
  136.      */
  137.     public String toString(boolean detailed);
  138. }
  139.  
  140.